package com.macro.mall.tiny.modules.oms.enums;

import lombok.Getter;

/**
 * 订单状态枚举
 */
@Getter
public enum OrderStatusEnum {
    INQUIRY(0, "询价"),
    QUOTATION(1, "报价"),
    DESIGN(2, "设计"),
    PRODUCTION(3, "制作"),
    DELIVERY(4, "配送/安装"),
    SETTLEMENT(5, "结算资料对接"),
    WAITING_PAYMENT(6, "等待付款"),
    COMPLETED(7, "已完成"),
    CANCELLED(8, "已废弃");

    private final Integer code;
    private final String description;

    OrderStatusEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据状态码获取枚举
     */
    public static OrderStatusEnum fromCode(Integer code) {
        for (OrderStatusEnum status : OrderStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    /**
     * 获取状态描述
     */
    public static String getDescriptionByCode(Integer code) {
        OrderStatusEnum status = fromCode(code);
        return status != null ? status.getDescription() : "未知状态";
    }
}